<template>
  <el-table
    :data="applyForList"
    style="width: 100%"
    max-height="250"
    stripe
  >

    <el-table-column
      prop="groupName"
      label="群聊名"
      width="250"
    />

    <el-table-column
      prop="groupId"
      label="群号"
    />

    <el-table-column
      prop="fromId"
      label="邀请人"
    />

    <el-table-column
      prop="nick"
      label="邀请人昵称"
    />

    <el-table-column
      prop="message"
      label="消息"
    />

    <el-table-column
      fixed="right"
      label="操作"
      width="250"
    >
      <template slot-scope="scope">
        <el-button
          type="text"
          size="small"
          style="color: red"
          @click="agree(scope.row)"
        >同意加入</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>

import { respBotInvitedJoinGroupRequestEvent } from '@/api/bot'

export default {
  props: {
    applyForList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  methods: {
    agree(item) {
      respBotInvitedJoinGroupRequestEvent(item).then(res => {
        this.$message({
          type: 'success',
          message: res
        })
        setTimeout(() => {
          this.$emit('agreeGroup')
        }, 1000)
      }).catch(err => {
        this.$message.error(err)
      })
    }
  }
}
</script>

<style scoped>

</style>
